import './assets/main.css'
import { createApp } from 'vue'
import App from './App.vue'
import { createPinia } from 'pinia'

import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import '@renderer/assets/scss/element-variables.scss'
import '@renderer/assets/fonts/font.scss'

import router from './router'
import i18n from './lang/index'

import commonDirective from '@renderer/directive'

import * as ElementPlusIconsVue from '@element-plus/icons-vue'

const app = createApp(App)
const pinia = createPinia()

for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component)
}

// app.directive('minMaxValue', {
//     mounted(el, params) {
//         el.querySelector("input").addEventListener("focusout", (event) => {
//             let nature = params.value
//             let value = event.target.value

//             if (value != '' && value != undefined) {
//                 if (nature.min != undefined) {
//                     value = value < nature.min ? nature.min : value
//                 }
//                 if (nature.max != undefined) {
//                     value = value > nature.max ? nature.max : value
//                 }
//                 event.target.value = value
//                 el.querySelector("input").dispatchEvent(new Event("input"))
//             }
//         })
//     }
// })

app.use(ElementPlus)
app.use(i18n)
app.use(pinia)
app.use(router)
app.use(commonDirective)
app.mount('#app')
